package demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component
public class User {
    private String name;

    public User() {
        System.out.println("User的构造方法执行了");
    }

    public String getName() {
        return name;
    }

    @Value("李四")
    public void setName(String name) {
        this.name = name;
        System.out.println("name属性的set方法:setName()被调用了");
    }

    @PostConstruct
    public void init() {
        System.out.println("Spring容器初始化User对象了,调用了@PostConstruct标注的方法");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("Spring容器销毁User对象了,调用了@PreDestroy标注的方法");
    }
}
